#include <QApplication>
#include <QLabel>
#include <QFont>
#include <QShortcut>
#include <QMainWindow>
#include <QStatusBar>
#include <QDebug>
#include <QyLexerFactory>
#include <Qsci/qscilexercpp.h>

#include "QyEditorBase.h"
/*
class QyCPPLexerFactory : public QyLexerFactory {
public:
	QyCPPLexerFactory() : QyLexerFactory( "*.h;*.hpp;*.hxx;*.hh;*.c;*.cpp;*.cxx;*.cc" )
		{ p_lexer = new QsciLexerCPP; }
	~QyCPPLexerFactory() { delete p_lexer; }

	QsciLexer * lexer() const { return p_lexer; }

private:
	QsciLexerCPP * p_lexer;

};
*/
int main( int argc, char ** argv ) {

	QApplication app( argc, argv );

	app.setFont( QFont( "terminus", 10 ) );

	QMainWindow mw;
	QyEditorBase * w = new QyEditorBase(&mw);
	QLabel * label = new QLabel(&mw);

	// new QyCPPLexerFactory;

	mw.statusBar()->addWidget(label);
	mw.setCentralWidget(w);
	mw.show();
	mw.resize( 800, 600 );

	w->openEmpty("line 1");
	w->openEmpty("line 2");
	w->openEmpty("line 3");
	w->openEmpty("line 4");
	w->openEmpty("line 5");

	new QShortcut( QKeySequence("Ctrl+N"), w, SLOT( openEmpty() ) );
	new QShortcut( QKeySequence("Ctrl+O"), w, SLOT( openFile() ) );
	new QShortcut( QKeySequence("Ctrl+S"), w, SLOT( saveCurrent() ) );
	new QShortcut( QKeySequence("Ctrl+Shift+S"), w, SLOT( saveCurrentAs() ) );
	new QShortcut( QKeySequence("Ctrl+W"), w, SLOT( closeCurrent() ) );
	new QShortcut( QKeySequence("Ctrl+Shift+W"), w, SLOT( closeCurrentSection() ) );
	new QShortcut( QKeySequence("Ctrl+Shift+Alt+W"), w, SLOT( clear() ) );
	new QShortcut( QKeySequence("Ctrl+F"), w, SLOT( findText() ) );
	new QShortcut( QKeySequence("F3"), w, SLOT( findTextNext() ) );

	QObject::connect( w, SIGNAL( statusChanged(const QString&) ),
		label, SLOT( setText(const QString&) ) );

	return app.exec();
}
